package com.lunduhotel.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lunduhotel.dao.QuartoDao;
import com.lunduhotel.modelo.Quarto;

@WebServlet("/ServletAddQuarto")
public class ServletAddQuarto extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public ServletAddQuarto() {
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	Quarto quarto = new Quarto();
	quarto.setId(Integer.parseInt(request.getParameter("id_quarto")));
	quarto.setTipo(request.getParameter("tipoQuarto"));
	quarto.setValor(Float.parseFloat(request.getParameter("valor")));
	quarto.setQuantCama(Integer.parseInt(request.getParameter("camaSolt")));
	quarto.setQuantCamaCasal(Integer.parseInt(request.getParameter("camaCas")));
	QuartoDao quartoDao = new QuartoDao();
	quartoDao.adicionarQuarto(quarto);
	request.setAttribute("msg", "Quarto adicionado com sucesso!");
	request.getRequestDispatcher("addQuarto.jsp").forward(request, response);
	
	
	}

}